
import xml.dom.minidom

#try:
#    fd = open('./files/init.xml','r')
#    x = fd.read()
#except:
#    print('fd error')

#print(x)
def xml_test():
    dom = xml.dom.minidom.parse('./files/init.xml')
    root = dom.documentElement 
    #print(root.nodeName)
    #print(root.nodeValue)


    bag = root.getElementsByTagName('module')
    for mod in bag:
        #print(mod.firstChild.data)
        print(mod.getAttribute('style'))
        print(mod.getElementsByTagName('id')[0].firstChild.data)
        print(mod.getElementsByTagName('name')[0].firstChild.data)
    #print(i)

#classes = school.getElementsByTagName("modules-style")
#    print( "There are %d classes in school %s" %(classes.length, school.getAttribute("name")) )
#    for mclass in classes:
#        print(mclass.getAttribute("Id"))
#        for student in mclass.getElementsByTagName("Student"):
#            print(student.attributes["Name"].value)
#            print(student.getElementsByTagName("English")[0].nodeValue) #这个为什么啊？
#            print(student.getElementsByTagName("English")[0].childNodes[0].nodeValue)
#            student.getElementsByTagName("English")[0].childNodes[0].nodeValue = 75


